package com.example.drools_service.service;

import com.gientech.drools_service.entity.City;
import com.gientech.drools_service.entity.Custom;
import org.kie.api.KieBase;
import org.kie.api.runtime.KieSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RuleService {
    @Autowired
    private KieBase kieBase;

    public Custom executeRule(Custom custom, City city){
        KieSession kieSession = kieBase.newKieSession();

        //插入事实对象
        kieSession.insert(custom);
        kieSession.insert(city);
        kieSession.fireAllRules();
        kieSession.dispose();

        return custom;
    }
}
